let map;
function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: YOUR_LATITUDE, lng: YOUR_LONGITUDE},
    zoom: 12
  });

  // 添加起点和终点标记
  const startPoint = new google.maps.Marker({
    position: {lat: START_LATITUDE, lng: START_LONGITUDE},
    map: map,
    title: '起点'
  });

  const endPoint = new google.maps.Marker({
    position: {lat: END_LATITUDE, lng: END_LONGITUDE},
    map: map,
    title: '终点'
  });

  // 绘制路线
  const directionsService = new google.maps.DirectionsService();
  const directionsRenderer = new google.maps.DirectionsRenderer({map: map});
  const request = {
    origin: startPoint.position,
    destination: endPoint.position,
    travelMode: 'DRIVING'
  };
  directionsService.route(request, function(response, status) {
    if (status === 'OK') {
      directionsRenderer.setDirections(response);
    } else {
      window.alert('获取导航路线失败：' + status);
    }
  });
}